package com.binyouwei.designpatterns.behavior.command;

/**
 * @author 宾有为
 * Created on 2024/7/15 22:53
 * Social homepage: https://blog.csdn.net/baidu_41616022
 * @desc 遥控器类
 **/
public class RemoteControl {
    Command commandSlot;

    public RemoteControl() {
        commandSlot = null;
    }

    public void setCommand(Command command) {
        commandSlot = command;
    }

    public void buttonWasPressed() {
        commandSlot.execute();
    }

    public void buttonWasReleased() {
        commandSlot.undo();
    }
}
